# -*- coding: utf-8 -*-
"""
Author:duan
Date: 2021/3/4 23:12
"""
import pika

credentials = pika.PlainCredentials('guest', 'guest')
connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='127.0.0.1', credentials=credentials))
channel = connection.channel()
channel.exchange_declare(exchange='ex3', exchange_type='direct')
# 声明一个名为ex3的交换器，发布类型为集体分发
channel.basic_publish(exchange='ex3',
                      routing_key='test01',
                      body="everyone on ex1 and routing_key is test01 will get this msg!")  # noqa

# 往ex1中所有队列分发消息
connection.close()
